<?php

/**
 * Define const
 *
 * @author ThaiNV
 *
 */
class Constants
{
  const SALT = "!@#$%^&*";
  const ENCRIPT_KEY = "123456789!@#$%^&";
  const RECORD_OF_PAGE = 20;
  const DELETE_FLAG_FALSE = '0';
  const DELETE_FLAG_TRUE = '1';

  const STATUS_INACTIVE = '0';
  const STATUS_ACTIVE = '1';
  const STATUS_FAIL = '-1';
  const STATUS_REMOVE = '-9';

  const MENU_HOME = 'site';
  const MENU_CATEGORY = 'categories';
  const MENU_USER = 'users';
  const MENU_IMAGE = 'image';
  const MENU_MEMBERS = 'members';
  const MENU_SITES = 'sites';
  const MENU_ACCOUNTS = 'account';
  const MENU_CAPTCHA = 'captcha';
  const MENU_TRACKING = 'tracking';

  const RESPONSE_SUCCESS = 1;
  const RESPONSE_ERROR = 0;
  const RESPONSE_NOT_AUTHENTICATE = 0;

  //member status
  const MEMBER_ACTIVE = 1;
  const MEMBER_INACTIVE = 0;
  const MEMBER_DELETE = -9;

  const MEMBER_TYPE_USER = 1;
  const MEMBER_TYPE_ADMIN = 2;

  //account status
  const ACCOUNT_ACTIVE = 1;
  const ACCOUNT_PENDING = 0;
  const ACCOUNT_DELETE = -9;

  //site status
  const SITE_ACTIVE = 1;
  const SITE_PENDING = 0;
  const SITE_DELETE = -9;

  //ad status
  const AD_SUCCESS = 1;
  const AD_FAIL = 0;

  //grid status
  const GRID_SUCCESS = 1;
  const GRID_FAIL = 0;

  //captcha status
  const CAP_NEW = 0;
  const CAP_PROCESSING = 1;
  const CAP_ANSWER = 2;
  const CAP_SUCCESS = 3;
  const CAP_FAIL = -9;

  const DIR_CAPTCHA = '/images/data/';

  public static function getMemberStatus() {
    return array(self::MEMBER_ACTIVE => "Active", self::MEMBER_INACTIVE => "Pending", self::MEMBER_DELETE => "Remove");
  }

  public static function getAccountStatus() {
    return array(self::ACCOUNT_ACTIVE => "Active", self::ACCOUNT_PENDING => "Pending", self::ACCOUNT_DELETE => "Remove");
  }

  public static function getSiteStatus() {
    return array(self::SITE_ACTIVE => "Active", self::SITE_PENDING => "Pending", self::SITE_DELETE => "Remove");
  }

  public static function getAdStatus() {
    return array(self::AD_SUCCESS => "Success", self::AD_FAIL => "Fail");
  }

  public static function getGridStatus() {
    return array(self::GRID_SUCCESS => "Success", self::GRID_FAIL => "Fail");
  }

  public static function getMemberType() {
    return array(self::MEMBER_TYPE_USER => "User", self::MEMBER_TYPE_ADMIN => "Admin");
  }
  
  public static function isAdmin() {
    if (Yii::app()->user->getState('roles') == 'admin') {
      return true;
    }

    return false;
  }
}

